package com.treehouse.rpgdefender.system;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Mapper;
import com.artemis.systems.EntityProcessingSystem;
import com.treehouse.rpgdefender.component.Body;
import com.treehouse.rpgdefender.component.Select;

/**
 * System class for selection logic between entities with body and select
 * components.
 * 
 * @author Julian Biermann
 * @version 26.02.2013 14:29:08 v1.0
 * 
 */
public class BodySelectSystem extends EntityProcessingSystem {

	private GameContainer container;

	private Input input;

	@Mapper
	private ComponentMapper<Body> bodyMapper;
	@Mapper
	private ComponentMapper<Select> selectMapper;

	private boolean isMousePressed;
	private boolean isMouseReleased;

	/**
	 * Initialize the system.
	 * 
	 * @param container
	 *            Game container reference.
	 */
	@SuppressWarnings("unchecked")
	public BodySelectSystem(GameContainer container) {
		super(Aspect.getAspectForAll(Body.class, Select.class));
		this.container = container;
		this.input = this.container.getInput();
		this.isMousePressed = false;
		this.isMouseReleased = true;
	}

	@Override
	protected void initialize() {
		this.bodyMapper = world.getMapper(Body.class);
		this.selectMapper = world.getMapper(Select.class);
	}

	@Override
	protected void process(Entity e) {
		Body body = this.bodyMapper.get(e);
		Select select = this.selectMapper.get(e);

		// TODO: Rework or find a solution for input selection. Entities are
				// selected while the mouse key is down and not pressed. Entities should
				// only be selected when the key was pressed and got released, while to
				// cursor is in the body.
	}

	@Override
	protected boolean checkProcessing() {
		return true;
	}
}
